package lois;

import java.util.Random;

public class LoiNormale extends Loi {
	private double moyenne;
	private double ecartType;
	
	public LoiNormale(double moyenne, double  ecartType) {
		this.moyenne = moyenne;
		this.ecartType = ecartType;
	}
	
	public double generer() {
		return boxMuller(Math.random(), Math.random());
	}
	
	private double boxMuller(double U1, double U2) {
		double rand = Math.sqrt(-2D*Math.log(U1))*Math.cos(Math.PI*2D*U2); 
		return moyenne + ecartType*rand;
	}

}
